﻿using Course.Infrastructure.Dto.Respone;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Course.Service.Instance
{
    public class CouresService
    {
        /// <summary>
        ///
        /// </summary> <param name="code">>0:ok <=0:fail</param> <param name="message"></param>
        /// <param name="data"></param> <returns></returns>
        protected ApiResult GetResult(int code, string message = "", object? data = null)
        {
            var result = new ApiResult()
            {
                data = data
            };
            if (code > 0)
            {
                result.code = ApiCode.ok;
                result.message = "操作成功";
            }
            else
            {
                result.code = ApiCode.fail;
                result.message = "操作失败";
            }

            if (!string.IsNullOrEmpty(message))
            {
                result.message = message;
            }
            return result;
        }
    }
}
